package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VVorder;
import com.ruoyi.system.service.IVVorderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author colin
 * @date 2021-09-17
 */
@Controller
@RequestMapping("/system/vorder")
public class VVorderController extends BaseController
{
    private String prefix = "system/vorder";

    @Autowired
    private IVVorderService vVorderService;

    @RequiresPermissions("system:vorder:view")
    @GetMapping()
    public String vorder()
    {
        return prefix + "/vorder";
    }

    /**
     * 查询VIEW列表
     */
    @RequiresPermissions("system:vorder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(VVorder vVorder)
    {
        startPage();
        List<VVorder> list = vVorderService.selectVVorderList(vVorder);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @RequiresPermissions("system:vorder:export")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VVorder vVorder)
    {
        List<VVorder> list = vVorderService.selectVVorderList(vVorder);
        ExcelUtil<VVorder> util = new ExcelUtil<VVorder>(VVorder.class);
        return util.exportExcel(list, "VIEW数据");
    }

    /**
     * 新增VIEW
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存VIEW
     */
    @RequiresPermissions("system:vorder:add")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(VVorder vVorder)
    {
        return toAjax(vVorderService.insertVVorder(vVorder));
    }

    /**
     * 修改VIEW
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        VVorder vVorder = vVorderService.selectVVorderById(id);
        mmap.put("vVorder", vVorder);
        return prefix + "/edit";
    }

    /**
     * 修改保存VIEW
     */
    @RequiresPermissions("system:vorder:edit")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(VVorder vVorder)
    {
        return toAjax(vVorderService.updateVVorder(vVorder));
    }

    /**
     * 删除VIEW
     */
    @RequiresPermissions("system:vorder:remove")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(vVorderService.deleteVVorderByIds(ids));
    }
}
